# HZip src目录构建脚本

import os

# 导入环境
Import('env')

# 获取构建目录
build_dir = 'build'

# 创建各模块的构建环境副本
core_env = env.Clone()
formats_env = env.Clone()
ui_env = env.Clone()
tracker_env = env.Clone()

# 核心模块源文件
core_sources = [
    'core/HZipEngine.cpp'
]

# 格式模块源文件
formats_sources = [
    'formats/ZipFormat.cpp',
    'formats/TarFormat.cpp',
    'formats/GzipFormat.cpp',
    'formats/Bzip2Format.cpp'
]

# UI模块源文件
ui_sources = [
    'ui/MainWindow.cpp'
]

# 主程序源文件
main_sources = ['main.cpp']

# 构建主程序
program_env = env.Clone()
program_sources = main_sources + core_sources + formats_sources + ui_sources
program = program_env.Program(os.path.join('#', build_dir, 'hzip'), program_sources)

# 设置主程序安装路径
program_install = program_env.Install('#', program)
program_env.Alias('install', program_install)

# Tracker插件源文件
tracker_sources = [
    'tracker/TrackerAddOn.cpp'
] + core_sources + formats_sources

# 构建Tracker插件
tracker_addon = tracker_env.SharedLibrary(os.path.join('#', build_dir, 'HZip'), tracker_sources)

# 设置Tracker插件安装路径
if os.name == 'posix':  # Haiku是POSIX兼容的
    tracker_install_dir = '/boot/system/add-ons/Tracker'
    tracker_install = tracker_env.Install(tracker_install_dir, tracker_addon)
    tracker_env.Alias('install-tracker', tracker_install)

# 默认目标
Default(program, tracker_addon)